package com.yy.job.common.enums;

import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;

public enum YesOrNoEnum {
	
	YES("Y","是"), NO("N", "否");
	
	private String code;
	private String name;

	YesOrNoEnum(String code, String name) {
		this.code = code;
		this.name = name;
	}

	public String getCode() {
		return this.code;
	}

	public String getName() {
		return this.name;
	}

	public static YesOrNoEnum findByCode(String code) {
		if (StringUtils.isEmpty(code)) {
			return null;
		}

		return Stream.of(YesOrNoEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
	}
	
}
